<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>贵州文化历史网</title>
  <meta name="keywords" content="个人博客,杨青个人博客,个人博客模板,杨青" />
  <meta name="description" content="杨青个人博客，是一个站在web前端设计之路的女程序员个人网站，提供个人博客模板免费资源下载的个人原创网站。" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="__static__/home/css/base.css" rel="stylesheet">
  <link href="__static__/home/css/about.css" rel="stylesheet">
  <link href="__static__/home/css/m.css" rel="stylesheet">
  <link  rel="stylesheet" href="__static__/pinglun/css/main.css" />
  <link rel="stylesheet" type="text/css" href="__static__/pinglun/css/sinaFaceAndEffec.css" />
  <script type="text/javascript" src="__static__/pinglun/js/jquery-1.8.3.min.js"></script>
  <script type="text/javascript" src="__static__/index/layui/layui.all.js"></script>
  <script>
    window.onload = function ()
    {
      var oH2 = document.getElementsByTagName("h2")[0];
      var oUl = document.getElementsByTagName("ul")[0];
      oH2.onclick = function ()
      {
        var style = oUl.style;
        style.display = style.display == "block" ? "none" : "block";
        oH2.className = style.display == "block" ? "open" : ""
      }
    }
  </script>
  <style >
    .ping{
    }
  </style>
</head>
<body>
<header>
  {include file="./public/top"}
</header>
<article>
  <h2 class="litle"><span>我学习了一生，现在我还在学习，而将来，只要我还有精力，我还要学习下去。</span></h2>
  <h3 style="padding: 5px;">{$Request.session.username} 修改信息</h3>
  <div class="ab_box">
    <div class="leftbox">
      <div class="newsview">
        <div class="news_infos" style="font-size: 17px;">
          <span style="text-indent:2em;"></span>

        </div>
        <div class="user_edit">
          <form class="layui-form" action="" method="post">
            <div class="layui-form-item">
              <label class="layui-form-label">昵称</label>
              <div class="layui-input-block">
                <input type="text" value="{$user.name}" style="width: 250px;" name="name" lay-verify="title" autocomplete="off" class="layui-input">
              </div>
            </div>

            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-inline">
                  <input type="tel" value="{$user.phone}" style="width: 250px;" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input">
                </div>
              </div>
            </div>

            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" style="width: 250px;" name="new_password" lay-verify="required|phone" autocomplete="off" class="layui-input">
                </div>
              </div>
            </div>

            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" style="width: 250px;" name="re_password" lay-verify="required|phone" autocomplete="off" class="layui-input">
                </div>
              </div>
            </div>
            <div class="btn" style="margin-left: 10%;">
              <button type="button" onclick="edit({$Request.session.userid})" class="layui-btn">确认修改</button>
              <button type="button" onclick="index()" class="layui-btn layui-btn-normal">返回</button>
            </div>

          </form>
        </div>
      </div>
    </div>
    <div class="rightbox">
      <div class="aboutme">
        <h2 class="hometitle">关于我</h2>
        <div class="avatar"> <img src="__static__/home/images/b04.jpg"> </div>
        <div class="ab_con">
          <p>网名：dancesmile | 兰艳</p>
          <p>职业：Web前端设计师、网页设计 </p>
          <p>个人微信：yangqq_1987</p>
          <p>邮箱：dancesmiling@qq.com</p>

        </div>
      </div>
      <div class="weixin">
        <h2 class="hometitle">官方微信</h2>
        <ul>
          <img src="__static__/home/images/wx.jpg">
        </ul>
      </div>
    </div>
  </div>
</article>
<script type="text/javascript" src="__static__/pinglun/js/main.js"></script>
<script type="text/javascript" src="__static__/pinglun/js/sinaFaceAndEffec.js"></script>

<script>

  function index() {
    window.location.href = "{:url('index/user/index', array('id' => $Request.session.userid))}"
  }

  function edit(uid){
    var id = uid
    var name = $(" input[ name='name' ] ").val()
    var phone = $(" input[ name='phone' ] ").val()
    var new_password = $(" input[ name='new_password' ] ").val()
    var re_password = $(" input[ name='re_password' ] ").val()
    if (name == ''){
      return layer.msg('呢称为空',{icon:2})
    }
    if (phone == ''){
      return layer.msg('手机号为空',{icon:2})
    }
    if (new_password != ''){
      if (new_password != re_password){
        return layer.msg('两次密码不一致',{icon:2})
      }
    }

    $.ajax({
      type: 'post',
      url: "{:url('index/user/edit')}",
      data: { id: id, phone: phone, name: name, password: new_password },
      dataType: 'json',
      success: function (res) {
        if (res.code == 1) {
          layer.msg(res.msg, { icon: 1, time: 1000 });
          setTimeout(function () {
            window.location.href = "{:url('index/admin/logout')}"
          }, 1000)
        } else{
          layer.msg(res.msg);
        }

      },
      error: function (res) {
        console.log(res.msg);
      },
    });


  }

  // layui.use(['element', 'layer'], function(){
  //   var element = layui.element;
  //   var layer = layui.layer;
  //
  //   //监听折叠
  //   element.on('collapse(test)', function(data){
  //     layer.msg('展开状态：'+ data.show);
  //   });
  // });
</script>

</body>
</html>
